package com.biz.user.config;

import org.springframework.context.annotation.*;

import java.util.concurrent.*;

/**
 * @Description
 *  自定义线池
 * @Author liuxi
 * @Date 2024/5/8
 **/
@Configuration
public class ThreadPollConfig {

    @Bean(name = "mailThreadPool")
    public ThreadPoolExecutor getMailThreadPool() {
        CustomNameThreadFactory mail = new CustomNameThreadFactory("mail");
        return new ThreadPoolExecutor(20, 50, 5,
                TimeUnit.SECONDS, new LinkedBlockingQueue<>(50), mail,
                new ThreadPoolExecutor.DiscardPolicy());
    }
}
